<template>
  <div class="msg-tip">
    <TbTitle title="四、本年度开展活动情况" />
    <TbTitle level="2" title="（一）本年度在本行政区域内开展公益活动情况" />
    <div style="display: flex; align-items: center">
      本年度是否开展活动：
      <el-switch inline-prompt v-model="yes" disabled active-text="是" inactive-text="否">
      </el-switch>
    </div>
  </div>

  <template v-for="(item, index) in detailInfo">
    <table border="0" class="m-table">
      <tr>
        <td rowspan="2" style="width: 50px">序号</td>
        <td rowspan="2">活动(项目)名称</td>
        <td rowspan="2">类型</td>
        <td rowspan="2">活动进行方式</td>
        <td colspan="2">活动时间</td>
        <td rowspan="2">活动地点（20字内，填至区县）</td>
        <td rowspan="2">收入情况（元）</td>
        <td rowspan="2">支出情况（元）</td>
        <td rowspan="2" style="width: 70px">参与人数</td>
      </tr>
      <tr>
        <td>开始日期</td>
        <td>结束日期</td>
      </tr>
      <tr>
        <td rowspan="3">{{ item.index }}</td>
        <td>
          {{ item.activityName }}
        </td>
        <td>
          {{ dictToVal(dict1, item.activityType) }}
        </td>
        <td>
          {{ dictToVal(dict2, item.conductMode) }}
        </td>
        <td>
          {{ item.startTime }}
        </td>
        <td>
          {{ item.endTime }}
        </td>
        <td>
          {{ item.address }}
        </td>
        <td>
          {{ item.feeSituation }}
        </td>
        <td>
          {{ item.expenditureSituation }}
        </td>
        <td>
          {{ item.participantsNum }}
        </td>
      </tr>
      <tr>
        <td colspan="10">活动介绍(含经济效益、社会效益等介绍200字)</td>
      </tr>
      <tr style="height: 100px">
        <td colspan="11">
          {{ item.activityIntroduction }}
        </td>
      </tr>
    </table>
  </template>
  <div class="msg-tip">

  </div>
</template>

<script setup lang="ts">
import { ref, reactive, inject } from 'vue'
import TbTitle from '@/views/yearCheck/components/TbTitle.vue'
import { getDictByCode } from '@/views/yearCheck/ykb/mf/mf'

let yes = ref(false)
let detailInfo = reactive([])
const { getDetailInfo } = inject('getDetailInfo')


getDetailInfo().then(res => {
  yes.value = res.data.length == 0 ? false : true
  Object.assign(detailInfo, res.data)
})
const dict1 = ref([]);
const dict2 = ref([]);
getDictByCode("activityType").then(response => {
  dict1.value = response.data;
});
getDictByCode("activityOngoing").then(response => {
  dict2.value = response.data;
});

const dictToVal = (dictList, val) => {
  for (let i = 0; i < dictList.length; i++) {
    if (val == dictList[i].id) {
      return dictList[i].name
    }
  }
}
</script>
<style lang="scss" scoped>
.msg-tip {
  padding: 20px 0;
  color: #000;
  font-family: '微软雅黑';
}

table {
  margin-bottom: 20px;
}
</style>
